package interface3;

public class ClassDataInter2 implements ClassDataInter
{
    private Student students[];
    public ClassDataInter2(Student allstudents[])
    {
        this.students= allstudents;
    }
    @Override
    public void printAllstudentinfors()
    {
        int i = 0;
        int malecount = 0;
        System.out.println("全班信息如下：");
        for(i = 0;i<students.length;i++)
        {
            Student s = students[i];
            System.out.println("姓名：" + s.getName() +"性别："+ s.getSex() +"分数" + s.getScore() );
            if(s.getSex() == "男")
            {
                malecount++;
            }
        }
        System.out.println("全班共有"+ malecount +"位男学生");
        System.out.println("全班共有"+ (students.length-malecount) +"位女学生");

    }

    @Override
    public void printAverageScore()
    {
        double sum = students[0].getScore();
        double max = students[0].getScore();
        double min = students[0].getScore();
    int i = 0;
    for(i = 1;i<students.length;i++)
    {
        Student s = students[i];
        if(max < s.getScore())
        {
            max = s.getScore();
        }
        if(min > s.getScore())
        {
            min = s.getScore();
        }
        sum +=s.getScore();
    }
    System.out.println("全班平均分是：" + (sum - max - min)/(students.length-2));


    }


}
